package com.lancoo.znbkxx.teacher.adapter

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView

/**
 * @author : wealive
 * @date   : 2020/9/4 15:20
 * @desc   :
 */
class SpacesItemDecoration(private val spaceValue: HashMap<String, Int>) :
    RecyclerView.ItemDecoration() {
    companion object {
        val TOP_SPACE = "top_space"
        val BOTTOM_SPACE = "bottom_space"
        val LEFT_SPACE = "left_space"
        val RIGHT_SPACE = "right_space"
    }

    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ) {
        outRect.left = spaceValue[LEFT_SPACE] ?: 0
        outRect.right = spaceValue[RIGHT_SPACE] ?: 0
        outRect.bottom = spaceValue[BOTTOM_SPACE] ?: 0
        outRect.top = spaceValue[TOP_SPACE] ?: 0
    }
}